<?php
include "includes/sesiones.php";
include "includes/comunes.php";
if($_GET['crear']==1){
     $_SESSION['clinombre']=strtoupper($_GET["nombre"]);
    $_SESSION['cliapellido']=strtoupper($_GET["apellido"]);
    $_SESSION['clidni']=$_GET["dni"];

    header("Location: altacreditos.php");

}


$where=" where 1=1";
if(isset($_POST['Enviar'])){


  if(isset($_POST['dni']) and $_POST['dni']<>"")
      $where.=" and cliente=".trim($_POST['dni'])." ";
   if(isset($_POST['cre']) and $_POST['cre']<>"")
      $where.=" and id=".trim($_POST['cre'])." ";
   if(isset($_POST['fec']) and $_POST['fec']<>"")
      $where.=" and fecha='".trim($_POST['fec'])."'";
  if(isset($_POST['aut']) and $_POST['aut']<>"")
      $where.=" and autorizacion='".trim($_POST['aut'])."'";
  if(isset($_POST['est']) and $_POST['est']<>0)
      $where.=" and estado=".trim($_POST['est'])." ";
   if(isset($_POST['fin']) and $_POST['fin']<>0)
      $where.=" and financiera=".trim($_POST['fin'])." ";
   if(isset($_POST['tip']) and $_POST['tip']<>0)
      $where.=" and tipoCredito=".trim($_POST['tip'])." ";



   $sql="select * from creditos ".$where." order by id desc";

 
   $rescli= $consultar=  cons_ins($sql);

}
else{
$sql="select top 25 * from creditos order by id desc";

$rescli= cons_ins($sql);}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include "includes/metas.php";?>
    <script src="jquery/js/jquery-1.9.1.js"></script>
    <link rel="stylesheet" type="text/css" href="jquery/css/ui-flexigrid/flexigrid.css">
    <script type="text/javascript" src="jquery/js/flexigrid.js"></script>
    <script language="JavaScript" type="text/javascript">
$(function()
{
  $('#flex1').flexigrid({
      colModel : [
                
		{display: 'Nro', name : 'pedidoID', width : 50, sortable : true, align: 'center'},
		{display: 'Fecha', name : 'fecha', width : 60, sortable : true, align: 'left'},
		{display: 'Nombre y Apellido', name : 'nom', width : 150, sortable : true, align: 'left'},
		{display: 'Estado', name : 'est', width : 60, sortable : true, align: 'left'},
		{display: 'Entidad', name : 'destino', width : 150, sortable : true, align: 'left'},
                {display: 'NºAutor', name : 'creado', width : 60, sortable : true, align: 'left'},
                {display: 'Mor.', name : 'dias', width : 20, sortable : true, align: 'left'},
                {display: 'Acciones', name : 'acciones', width : 80, sortable : false, align: 'left'}
		],
                width: 715,
                height: 1000
                
                
              
  });

});
</script>
</head>

<body>
<div class="contenedor">
	<div class="cont">
    	<?php include "includes/head.php";?>
        <?php include "includes/menu.php";?>
        

    	<div class="novedadescont">
<!--            <div class="novedadestitulo">
            	<div class="menuvolver"> <a href="javascript:history.back(1)">Volver Atrás</a></div>
            </div>-->
            <div class="novedadestitulo">
            <div class="novetitulo2">Listado y Cobro de Creditos(Seleccione Filtros)</div>
            </div>
           
                <?php
                  if($_GET['credito'])
                      echo '<div class="mensaje">Se ha creado exitosamente el credito Nº <strong>'.$_GET['credito'].'</strong> &nbsp;&nbsp;&nbsp;<a href="ImprimirCredito.php?cre_id='.$_GET['credito'].'" target="_new"><img src="images/imprimir.png" border="0" width="25px" alt="Imprimir"/></a></div>'
                ?>


            
            <div class="formucont">
                 <form id="form1" name="form1" method="post" action="listadocreditos.php">
           	 

              <div class="formlinea">
                <div class="formtxt">Dni</div>
                <div class="formtxt2">
                    <input name="dni" type="text" id="form" size="25" />
                </div>
                </div>


                     <div class="formlinea">
                <div class="formtxt">Nº Credito</div>
                <div class="formtxt2">
                    <input name="cre" type="text" id="form" size="25" />
                </div>
                </div>

                      <div class="formlinea">
                <div class="formtxt">Fecha Otor</div>
                <div class="formtxt2">
                    <input name="fec" type="text" id="form" size="25" />
                </div>
                </div>
                <div class="formlinea">
                <div class="formtxt">Financiera</div>
                <div class="formtxt2">
                   <?php echo listar_financieras();?>
                </div>
                </div>

                     <div class="formlinea">
                <div class="formtxt">Estado</div>
                <div class="formtxt2">
                    <select name="est">
                        <option selected value="0">Todos</option>
                        <option  value="1">Pendiente</option>
                        <option  value="2">Aprobado</option>
                        <option  value="3">Anulado</option>
                        <option  value="4">Cancelado</option>
                     </select>
                </div>
                </div>
                   
                       <div class="formlinea">
                <div class="formtxt">Autorizacion</div>
                <div class="formtxt2">
                    <input name="aut" type="text" id="form" size="25" />
                </div>
                </div>
                      <div class="formlinea">
                <div class="formtxt">Tipo de Credito</div>
                <div class="formtxt2">
                    <select name="tip">
                        <option selected value="0">Todos</option>
                        <option  value="1">Nuevos</option>
                        <option  value="2">Refinanciados</option>
                     </select>
                </div>
                </div>


                 <div class="botcont">
                <input name="Enviar" class="bot" type="submit" value="Buscar" />
                </div>
                </form>
            </div> 


        	<div class="novedadestitulo">
            	<div class="novetitulo2">Resultado<br>
                </div>
            </div>
            
            <div style="align:left;"> <a href="valclientes.php"><img src="images/nuevo.png" border="0" width="40px" title="Nuevo Credito"/></a></div>
            <div class="listadocont">
            	<div class="listadocol2">
                    <table border="0" id="flex1" style="display:none;width: 80%">

<?php while (!$rescli->EOF):?>
  <tr class="listadolinea">
    <td class="bordetabla" ><?php echo $rescli->fields['id']?></td>
    <td class="bordetabla" ><?php echo $rescli->fields['fecha']?></td>
    <td class="bordetabla" >&nbsp;<?php echo obtener_cliente($rescli->fields['cliente'])?>&nbsp;</td>
    <td class="bordetabla" ><?php echo obtener_estado($rescli->fields['estado'])?></td>
    <td class="bordetabla" ><?php echo obtener_financiera($rescli->fields['financiera'])?></td>
    <td class="bordetabla" >&nbsp;<?php echo $rescli->fields['autorizacion']?></td>
    <td class="bordetabla" >&nbsp;<?php echo $rescli->fields['nivelMorosidad']?></td>
    <td  class="bordetabla" >
<!--     <a href="editarclientes.php?cre_id=<?php //echo $rescli->fields['id']?>"><img src="images/editar.png" border="0" width="25px" alt="Editar" title="Editar"/></a>-->
     <a href="pagocreditos.php?cre_id=<?php echo $rescli->fields['id']?>"><img src="images/visualizar.png" border="0" width="25px" alt="Visualizar" title="Visualizar"/></a>
     <a href="ImprimirCredito.php?cre_id=<?php echo $rescli->fields['id']?>" target="_new"><img src="images/imprimir.png" border="0" width="25px" alt="Imprimir" title="Imprimir"/></a>
<!--     <a href="EliminarCreditos.php?cre_id=<?php //echo $rescli->fields['id']?>"><img src="images/eliminar.jpg" border="0" width="25px" alt="Eliminar" title="Eliminar"/></a>-->

<!--    <a href="#"><img src="images/ref.png" border="0" width="80px"/></a>-->
    </td>
  </tr>
 <?php
  $rescli->MoveNext();
 endwhile ?>


</table>
                	
<!--                    <a href="#" class="listadolinea">Texto o nombre del listado.</a>                    -->
                </div>
<!--                <div class="listadocol">
                	<a href="#"><img src="images/ed.png" border="0" /></a>
                   <a href="#"><img src="images/vis.png" border="0" /></a>
					<a href="#"><img src="images/imp.png" border="0" /></a>
                	<a href="#"><img src="images/ref.png" border="0" /></a>
                    
                    
                </div>-->

                               </div>
            
            
            
            
        	<div class="novedadesbottom"></div>
        </div>
    
    
    
    
    <div class="separador"></div>
 <?php include "includes/menufooter.php";?>
    
    
	<div id="clearing"></div>    
    </div>
<div id="clearing"></div>
</div>
</body>
</html>
